package com.scoresystem.web.ui.view;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.scoresystem.model.Student;
import com.scoresystem.utils.JsonUtil;

import net.sf.json.JSONObject;
/**
 * 管理员查看学生信息界面
 * @author Administrator
 *
 */
public class ShowStuQueryView implements IShowable {

	@Override
	public void showView(JSONObject json, HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		response.setHeader("contentType", "text/html; charset=utf-8");
		request.setAttribute("json", json.toString());
		
		if(JsonUtil.getState(json).equals("success")){
			List<Student> list=JsonUtil.getStudents(json);
			request.setAttribute("list", list);
			request.getRequestDispatcher("/StudentInfo.jsp").forward(request, response);
		}
		else
			request.getRequestDispatcher("/AdminMain.jsp").forward(request, response);
	}

}
